package com.systemsjr.jrenterprise.customer;

import javax.swing.JTable;
import javax.swing.table.TableColumnModel;

import com.systemsjr.jrenterprise.customer.vo.CustomerVO;
import com.systemsjr.jrenterprise.utils.ServiceUtils;
import com.systemsjr.jrlib.richclient.BaseItemTable;

public class CustomerTable extends BaseItemTable<CustomerVO> {

	public CustomerTable() {
		
		super(new CustomerVO[]{}, "customers", new String[]{
				"phoneNumber",
				"name"
		});
	}

	@Override
	protected void configureTable(JTable table) {
		super.configureTable(table);
		TableColumnModel tcm = table.getColumnModel();
		tcm.getColumn(0).setPreferredWidth(20);
		tcm.getColumn(1).setPreferredWidth(70);
	}

	@Override
	protected Object[] getDefaultInitialData() {
		setInitialData(ServiceUtils.getCustomerService().loadAll().toArray());
		return getInitialData();
	}
}
